<template>
  <div class="age-box">
    <div class="title">
      <p>年龄比例</p>
      <img src="../images/dataScreen-title.png" alt="" />
    </div>
    <div ref="container" class="chart-container"></div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'
const option = {
  gird: {
    top: 0,
    bottom: 0,
    left: 0,
    right: 0,
  },
  tooltip: {
    trigger: 'item',
  },
  legend: {
    top: '10%',
    right: '2%',
    orient: 'vertical',
    textStyle: {
      color: '#fff',
    },
  },
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: ['40%', '70%'],
      avoidLabelOverlap: false,
      padAngle: 5,
      itemStyle: {
        borderRadius: 10,
      },
      label: {
        show: true,
        position: 'inside',
        color: '#fff',
      },

      labelLine: {
        show: false,
      },
      data: [
        { value: 1048, name: '0-10岁' },
        { value: 735, name: '10-20岁' },
        { value: 580, name: '20-30岁' },
        { value: 484, name: '30-60岁' },
        { value: 300, name: '60岁以上' },
      ],
    },
  ],
}
let container = ref()
onMounted(() => {
  let myChart = echarts.init(container.value)
  myChart.setOption(option)
})
</script>

<style lang="scss" scoped>
.age-box {
  width: 100%;
  height: 100%;
  background: url('../images/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  .title {
    padding-left: 20px;
    p {
      color: #fff;
    }
  }
  .chart-container {
    margin-top: 20px;
    height: 240px;
  }
}
</style>
